﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace xjjxmm.infrastructure.ToolKit;

public class TokenKit
{
    public string Type { get; set; } = string.Empty;

    public string Token { get; set; } = string.Empty;

    private TokenKit() { }

    public static TokenKit Parse(string token)
    {
        if (!token.StartsWith("Bearer"))
        {
            return new TokenKit
            {
                Token = token
            };
        }


        return new TokenKit
        {
            Type = "Bearer",
            Token = token.Substring(7)
        };
    }

    public static string Builder(TokenKit token)
    {
        return $"{token.Type} {token.Token}";
    }
}
